import { defineStore } from 'pinia'
import { ref } from 'vue'
import { reqCategoryData } from '@/apis/layout'

export const useCategoryStore = defineStore('category', () => {
	// state
	const categoryList = ref([])

	// actions
	async function getCategoryListData() {
		try {
			const res = await reqCategoryData()
			categoryList.value = res.result
		} catch (error) {
			ElMessage({
				type: 'error',
				message: error.response?.data?.error,
			})
		}
	}

	return {
		categoryList,
		getCategoryListData,
	}
})
